package v2

import (
	"eci-forward/pkg/eci"
	"eci-forward/pkg/logs"

	"github.com/gin-gonic/gin"
)

func ECIDescribeAvailableResource(c *gin.Context) {
	gpuType := c.Query("gpu_type")
	if gpuType == "" {
		logs.Logger.Info("gpuType is empty, describe all gpus")
	}
	departmentName := c.Query("department_name")
	if departmentName == "" {
		c.JSON(400, gin.H{
			"message": "department_name can not be empty",
		})
		return
	}
	res, err := eci.DescribeAvailableResource(departmentName, "InstanceType", gpuType)
	if err != nil {
		c.JSON(500, gin.H{
			"message": err.Error(),
			"data":    nil,
		})
		return
	}
	c.JSON(200, gin.H{
		"message": "success",
		"data":    res,
	})
}
